Component({
  properties: {
    images: Array
  },

  data: {
    width: null,
    lazyLoad: true,
    defaultImg: "/assets/images/img/icon-unlogin.png",
    loading: true
  },

  lifetimes: {
    ready() {
      let that = this;
      let selQuery = wx.createSelectorQuery().in(this);
      selQuery
        .select(".img-grids")
        .boundingClientRect(res => {
          that.setData({
            width: res.width / 3.5
          });
        })
        .exec();
    }
  },

  methods: {
    previewImage(e) {
      let imgs = this.data.images;
      let id = e.currentTarget.dataset.index;
      wx.previewImage({
        current: imgs[id],
        urls: imgs
      });
    },

    imageLoad() {
      this.setData({ loading: false });
    },

    imageError() {
      console.log("图片加载异常");
    }
  }
});
